* NOTE: this commit removes any semblence of tsearch compatibility with pre-8.3 PostgreSQL
* Make new-installer work against PostgreSQL
* Remove SearchPostgres.php's call to pg_fetch_result. I think this is the only one outside of the vestigtial old installer code.
}
// Try to connect
- $status->merge( $this->getConnection() );
+ $status->merge( $this->getConnection( 'template1' ) );
if ( !$status->isOK() ) {
return $status;
}
return $status;
}
+ function getConnection($database = null) {
+ $status = Status::newGood();
+
+ if( is_null( $database ) ) {
+ $dbname = $this->getVar( 'wgDBname' );
+ $dbuser = $this->getVar( 'wgDBuser' );
+ $dbpass = $this->getVar( 'wgDBpassword' );
+ } else {
+ $dbname = $database;
+ $dbuser = $this->getVar( '_InstallUser' );
+ $dbpass = $this->getVar( '_InstallPassword' );
+ }
+
+ try {
+ $this->db = new DatabasePostgres(
+ $this->getVar( 'wgDBserver' ),
+ $dbuser, $dbpass, $dbname );
+ $status->value = $this->db;
+ } catch ( DBConnectionError $e ) {
+ $status->fatal( 'config-connection-error', $e->getMessage() );
+ }
+ return $status;
+ }
+
protected function canCreateAccounts() {
- $status = $this->getConnection();
+ $status = $this->getConnection( 'template1' );
if ( !$status->isOK() ) {
return false;
}
}
function setupDatabase() {
- $status = $this->getConnection();
+ $status = $this->getConnection( 'template1' );
if ( !$status->isOK() ) {
return $status;
}
return Status::newGood();
}
- $status = $this->getConnection();
+ $status = $this->getConnection( 'template1' );
if ( !$status->isOK() ) {
return $status;
}
$db = $this->getVar( 'wgDBname' );
$this->db->selectDB( $db );
$safeuser = $this->db->addIdentifierQuotes( $this->getVar( 'wgDBuser' ) );
+ $safeusercheck = $this->db->addQuotes( $this->getVar( 'wgDBuser' ) );
$safepass = $this->db->addQuotes( $this->getVar( 'wgDBpassword' ) );
+
+ $rows = $this->db->numRows(
+ $this->db->query( "SELECT 1 FROM pg_catalog.pg_shadow WHERE usename = $safeusercheck" )
+ );
+ if ( $rows < 1 ) {
$res = $this->db->query( "CREATE USER $safeuser NOCREATEDB PASSWORD $safepass", __METHOD__ );
- return $status;
- if ( $res !== true ) {
- $status->fatal( 'config-install-user-failed', $this->getVar( 'wgDBuser' ) );
+ if ( $res !== true && !( $res instanceOf ResultWrapper ) ) {
+ $status->fatal( 'config-install-user-failed', $this->getVar( 'wgDBuser' ), $res );
+ }
}
return $status;
## TODO: Better output (example to catch: one 'two)
die ("Sorry, that was not a valid search string. Please go back and try again");
}
- $top = pg_fetch_result($res,0,0);
+ $top = $res->fetchRow();
+ $top = $top[0];
if ($top === "") { ## e.g. if only stopwords are used XXX return something better
$query = "SELECT page_id, page_namespace, page_title, 0 AS score ".
BEGIN;
SET client_min_messages = 'ERROR';
+DROP SEQUENCE IF EXISTS user_user_id_seq;
+DROP SEQUENCE IF EXISTS page_page_id_seq;
+DROP SEQUENCE IF EXISTS revision_rev_id_seq;
+DROP SEQUENCE IF EXISTS page_restrictions_id_seq;
+DROP SEQUENCE IF EXISTS ipblocks_ipb_id_seq;
+DROP SEQUENCE IF EXISTS recentchanges_rc_id_seq;
+DROP SEQUENCE IF EXISTS logging_log_id_seq;
+DROP SEQUENCE IF EXISTS trackbacks_tb_id_seq;
+DROP SEQUENCE IF EXISTS job_job_id_seq;
+DROP SEQUENCE IF EXISTS category_cat_id_seq;
+DROP FUNCTION IF EXISTS page_deleted();
+DROP FUNCTION IF EXISTS ts2_page_title();
+DROP FUNCTION IF EXISTS ts2_page_text();
+DROP FUNCTION IF EXISTS add_interwiki(TEXT,INT,SMALLINT);
+
CREATE SEQUENCE user_user_id_seq MINVALUE 0 START WITH 0;
CREATE TABLE mwuser ( -- replace reserved word 'user'
user_id INTEGER NOT NULL PRIMARY KEY DEFAULT nextval('user_user_id_seq'),
CREATE INDEX job_cmd_namespace_title ON job (job_cmd, job_namespace, job_title);
-- Tsearch2 2 stuff. Will fail if we don't have proper access to the tsearch2 tables
--- Note: if version 8.3 or higher, we remove the 'default' arg
+-- Version 8.3 or higher only. Previous versions would need another parmeter for to_tsvector.
-- Make sure you also change patch-tsearch2funcs.sql if the funcs below change.
ALTER TABLE page ADD titlevector tsvector;
$mw$
BEGIN
IF TG_OP = 'INSERT' THEN
- NEW.titlevector = to_tsvector('default',REPLACE(NEW.page_title,'/',' '));
+ NEW.titlevector = to_tsvector(REPLACE(NEW.page_title,'/',' '));
ELSIF NEW.page_title != OLD.page_title THEN
- NEW.titlevector := to_tsvector('default',REPLACE(NEW.page_title,'/',' '));
+ NEW.titlevector := to_tsvector(REPLACE(NEW.page_title,'/',' '));
END IF;
RETURN NEW;
END;
$mw$
BEGIN
IF TG_OP = 'INSERT' THEN
- NEW.textvector = to_tsvector('default',NEW.old_text);
+ NEW.textvector = to_tsvector(NEW.old_text);
ELSIF NEW.old_text != OLD.old_text THEN
- NEW.textvector := to_tsvector('default',NEW.old_text);
+ NEW.textvector := to_tsvector(NEW.old_text);
END IF;
RETURN NEW;
END;